<%@ page session="false"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>

<html>
<head>
<title>Hola Ajax</title>
<link rel="stylesheet"
	href="<c:url value="/resources/blueprint/screen.css" />"
	type="text/css" media="screen, projection">
<link rel="stylesheet"
	href="<c:url value="/resources/blueprint/print.css" />" type="text/css"
	media="print">
<link type="text/css" href="../css/jquery-ui-1.8.15.custom.css" rel="Stylesheet" />	


	
	
<!--[if lt IE 8]>
			<link rel="stylesheet" href="<c:url value="/resources/blueprint/ie.css" />" type="text/css" media="screen, projection">
		<![endif]-->
<link rel="stylesheet" href="<c:url value="/resources/popup.css" />"
	type="text/css" media="screen, projection">
<script type="text/javascript" src="../js/jquery-1.4.min.js" /></script>
<script type="text/javascript" src="../js/json.min.js" /></script>
<script type="text/javascript" src="../js/jquery-ui-1.8.15.custom.min.js"></script>
</head>
<body>
	<div class="container">
		<form id="loginForm">
			<label> <span>Email:</span> <input text-input" type="text"
				name="email" id="email" /> </label> <label> <span>Nombre:</span> <input
				text-input" type="text" name="name" id="name" /> </label> <input
				type="button" value="singIn" id="singIn"
				onclick="javascript:control()" />
		</form>
	</div>
	<table border=0 id="login">
		<tr>
			<td>mensaje:</td>
			<td>
				<div id="pru"></div>
			</td>
		</tr>
		<tr>
			<td><select id="resultSelect" name="resultSelect">

			</select>
			</td>
		</tr>
	</table>

	<input type="text" name="date" id="date"/>
</body>

<script type="text/javascript">
	/**
	 * Iterates on all the currencies and adds the options to the select object
	 * @return
	 */
	 
	 $(document).ready(function(){
		 $("#date").datepicker();
		 $("#singIn").button();
		 
	});
	
	function fillCharges(jsonData) {
		debugger;
		select = "#resultSelect";
		/*Default value*/
		var option = new Option("Seleccionar", "0");
		var dropdownList = $(select);
		if ($.browser.msie) {
			dropdownList[0].add(option);
		} else {
			dropdownList[0].add(option, null);
		}
		/*fill the select with the json data*/
		$.each($.parseJSON(jsonData), function() {
			var option = new Option(this.name, this.chargeId);
			var dropdownList = $(select);
			if ($.browser.msie) {
				dropdownList[0].add(option);
			} else {
				dropdownList[0].add(option, null);
			}
		});
	}

	function control() {
		var email = document.getElementById("email").value;
		var username = document.getElementById("name").value;
		$.get('sendMail', {
			mail : email,
			name : username
		}, fillCharges);
		
	}
</script>

</html>